﻿#include"FITKAcousticsSEASubSysMgrAdaptor.h"
#include "FITK_Component/FITKAcousticsModel/FITKAbstractSEASubSys.h"
#include "FITK_Component/FITKAcousticsModel/FITKSEASubSysGeoProp.h"
#include "FITKAcousticsSEASubSysMgrAdaptor.h"
#include "FITKAcousticsHDF5Writer.h"
#include "FITKAcousticsHDF5Reader.h"
#include "FITK_Interface/FITKInterfaceIO/FITKHDF5FileTool.h"

#include "FITK_Component/FITKAcousticsModel/FITKSEASubSysBeam.h"
#include "FITK_Component/FITKAcousticsModel/FITKSEASubSysShellPlate.h"
#include "FITK_Component/FITKAcousticsModel/FITKSEASubSysGeoProp.h"
#include "FITK_Interface/FITKInterfaceModel/FITKCoordinateSystem.h"
#include"FITK_Component/FITKAcousticsModel/FITKSEASubSysSemiInfiniteFluid.h"

#include "FITK_Component/FITKAcousticsModel/FITKSEASubSysCavity.h"
#include "FITK_Component/FITKAcousticsModel/FITKAbstractSEASubSys.h"
#include "FITK_Component/FITKAcousticsModel/FITKSEASubSysShellCurved.h"
#include "FITK_Component/FITKAcousticsModel/FITKSEASubSysSemiInfiniteFluid.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKAcousticsPhysics.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKAcousticsSpectraManager.h"


bool IO::FITKAcousticsSEASubSysMgrAdaptor::adaptR()
{
    Acoustics::FITKAcousticsSEASubSysManager* SubSysManagerP =
        dynamic_cast<Acoustics::FITKAcousticsSEASubSysManager*>(_dataObj);
    if (SubSysManagerP == nullptr || _reader == nullptr) return false;
    m_toolp = _reader->getHDF5FileTool();//初始化工具

    std::tuple<bool, H5::Group>Ret = m_toolp->openGp("SEAModel");//打开SEAMode组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group SEAModelGroup = std::get<1>(Ret);

    bool SEABeamsRet = false;
    bool SEAFlatPlatesRet = false;
    bool SEACavitysRet = false;
    bool SinglyCurvedShellsRet = false;
    bool DoubleCurvedShellRet = false;
    bool SemiIInfiniteFluidsllRet = false;
    //读取顺序敏感
    SEABeamsRet = this->readSEABeams(SEAModelGroup, SubSysManagerP);
    SEAFlatPlatesRet = this->readSEAFlatPlates(SEAModelGroup, SubSysManagerP);
    SinglyCurvedShellsRet = this->readSinglyCurvedShells(SEAModelGroup, SubSysManagerP);
    DoubleCurvedShellRet = this->readDoublyCurvedShells(SEAModelGroup, SubSysManagerP);
    SEACavitysRet = this->readSEACavitys(SEAModelGroup, SubSysManagerP);
    SemiIInfiniteFluidsllRet = this->readSemiIInfiniteFluids(SEAModelGroup, SubSysManagerP);
    return SEABeamsRet && SEAFlatPlatesRet&&SEACavitysRet&&SinglyCurvedShellsRet&&DoubleCurvedShellRet&&SemiIInfiniteFluidsllRet;
}

bool IO::FITKAcousticsSEASubSysMgrAdaptor::adaptW()
{
    Acoustics::FITKAcousticsSEASubSysManager* SubSysManagerP =
        dynamic_cast<Acoustics::FITKAcousticsSEASubSysManager*>(_dataObj);
    if (SubSysManagerP == nullptr || _writer == nullptr) return false;
    m_toolp = _writer->getHDF5FileTool();//初始化工具

    std::tuple<bool, H5::Group> Ret = m_toolp->createGp("SEAModel");     //创建SEAMode组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group SEAModelGroup = std::get<1>(Ret);
    bool SEABeamsRet = false;
    bool SEAFlatPlatesRet = false;
    bool SEACavitysRet = false;
    bool SinglyCurvedShellRet = false;
    bool DoubleCurvedShellRet = false;
    bool SemiIInfiniteFluidsllRet = false;
    QList<Acoustics::FITKAbstractSEASubSys*>SEABeams = SubSysManagerP->getSubSysByType(Acoustics::FITKAbstractSEASubSys::SEASubSysType::SEABeam);//梁
    QList<Acoustics::FITKAbstractSEASubSys*>SEAFlatPlates = SubSysManagerP->getSubSysByType(Acoustics::FITKAbstractSEASubSys::SEASubSysType::SEAFlatPlate);//平板
    QList<Acoustics::FITKAbstractSEASubSys*>SEACavitys = SubSysManagerP->getSubSysByType(Acoustics::FITKAbstractSEASubSys::SEASubSysType::SEACavity);//声腔
    QList<Acoustics::FITKAbstractSEASubSys*>SEASinglyCurvedShells = SubSysManagerP->getSubSysByType(Acoustics::FITKAbstractSEASubSys::SEASubSysType::SEASinglyCurvedShell);//单曲率板
    QList<Acoustics::FITKAbstractSEASubSys*>SEADoublyCurvedShells = SubSysManagerP->getSubSysByType(Acoustics::FITKAbstractSEASubSys::SEASubSysType::SEADoublyCurvedShell);//双曲率板
    QList<Acoustics::FITKAbstractSEASubSys*>SEASemiIInfiniteFluids = SubSysManagerP->getSubSysByType(Acoustics::FITKAbstractSEASubSys::SEASubSysType::SEASemiIInfiniteFluid);//半无限流体

    SEABeamsRet = this->writeSEABeams(SEAModelGroup, SEABeams);
    SEAFlatPlatesRet = this->writeSEAFlatPlates(SEAModelGroup, SEAFlatPlates);
    SEACavitysRet = this->writeSEACavitys(SEAModelGroup, SEACavitys);
    SinglyCurvedShellRet = this->writeSinglyCurvedShells(SEAModelGroup, SEASinglyCurvedShells);
    DoubleCurvedShellRet = this->writeDoublyCurvedShells(SEAModelGroup, SEADoublyCurvedShells);
    SemiIInfiniteFluidsllRet = this->writeSemiIInfiniteFluids(SEAModelGroup, SEASemiIInfiniteFluids);
    return SEABeamsRet && SEAFlatPlatesRet&&SEACavitysRet&&SinglyCurvedShellRet&&DoubleCurvedShellRet&&SemiIInfiniteFluidsllRet;
}
bool IO::FITKAcousticsSEASubSysMgrAdaptor::writeSEASubSysShell(H5::Group & gp, Acoustics::FITKAbstractSEASubSysShell * SubSysShell)
{
    if (SubSysShell == nullptr)
    {
        return false;
    }
    int FlexureSpectraID = SubSysShell->getFlexureSpectraID();//弯曲波频谱id
    int ExtensionSpectraID = SubSysShell->getExtensionSpectraID();// 拉伸波频谱id
    int ShearSpectraID = SubSysShell->getShearSpectraID();//剪切波频谱id
    bool FromUserSpectraState = SubSysShell->getFromUserSpectraState();//来自用户光谱开启状态
    bool FromPhysicalPropState = SubSysShell->getFromPhysicalPropState();//来自物理属性开启状态
    bool FromNoiseControlState = SubSysShell->getFromNoiseControlState();//来自噪声控制开启状态


    //本类
    m_toolp->writeGroupAttrInt(gp, "FlexureSpectraID", FlexureSpectraID);
    m_toolp->writeGroupAttrInt(gp, "ExtensionSpectraID", ExtensionSpectraID);
    m_toolp->writeGroupAttrInt(gp, "ShearSpectraID", ShearSpectraID);
    m_toolp->writeGroupAttrInt(gp, "FromUserSpectraState", FromUserSpectraState == true ? 1 : 0);
    m_toolp->writeGroupAttrInt(gp, "FromPhysicalPropState", FromPhysicalPropState == true ? 1 : 0);
    m_toolp->writeGroupAttrInt(gp, "FromNoiseControlState", FromNoiseControlState == true ? 1 : 0);


    //写父类FITKAbstractSEASubSysWithNodes数据
    Acoustics::FITKAbstractSEASubSysWithNodes* p1 = dynamic_cast<Acoustics::FITKAbstractSEASubSysWithNodes*>(SubSysShell);
    if (p1 == nullptr) { return false; }
    this->writeSEASubSysWithNodes(gp, p1);

    //写父类FITKSEASubSysShellRadiationWare数据
    Acoustics::FITKSEASubSysShellRadiationWare* p2 = dynamic_cast<Acoustics::FITKSEASubSysShellRadiationWare*>(SubSysShell);
    if (p2 == nullptr) { return false; }
    this->writeSEASubSysShellRadiationWare(gp, p2);
    return true;
}
bool IO::FITKAcousticsSEASubSysMgrAdaptor::readSEASubSysShell(H5::Group & gp, Acoustics::FITKAbstractSEASubSysShell * SubSysShell)
{
    if (SubSysShell == nullptr)
    {
        return false;
    }

    int FlexureSpectraID = -1;//弯曲波频谱id
    int ExtensionSpectraID = -1;// 拉伸波频谱id
    int ShearSpectraID = -1;//剪切波频谱id
    int FromUserSpectraState = false;//来自用户光谱开启状态
    int FromPhysicalPropState = false;//来自物理属性开启状态
    int FromNoiseControlState = false;//来自噪声控制开启状态

    //本类
    m_toolp->readGroupint(gp, "FlexureSpectraID", &FlexureSpectraID);
    m_toolp->readGroupint(gp, "ExtensionSpectraID", &ExtensionSpectraID);
    m_toolp->readGroupint(gp, "ShearSpectraID", &ShearSpectraID);
    m_toolp->readGroupint(gp, "FromUserSpectraState", &FromUserSpectraState);
    m_toolp->readGroupint(gp, "FromPhysicalPropState", &FromPhysicalPropState);
    m_toolp->readGroupint(gp, "FromNoiseControlState", &FromNoiseControlState);

    SubSysShell->setFlexureSpectraID(FlexureSpectraID);
    SubSysShell->setExtensionSpectraID(ExtensionSpectraID);
    SubSysShell->setShearSpectraID(ShearSpectraID);
    SubSysShell->setFromUserSpectraState(FromUserSpectraState);
    SubSysShell->setFromPhysicalPropState(FromPhysicalPropState);
    SubSysShell->setFromNoiseControlState(FromNoiseControlState);


    //父类FITKAbstractSEASubSysWithNodes
    Acoustics::FITKAbstractSEASubSysWithNodes* p1 =
        dynamic_cast<Acoustics::FITKAbstractSEASubSysWithNodes*>(SubSysShell);
    if (p1 == nullptr)
    {
        return false;
    }
    this->readSEASubSysWithNodes(gp, p1);//读取基类数据，并填充

    //父类FITKSEASubSysShellRadiationWare
    Acoustics::FITKSEASubSysShellRadiationWare* p2 =
        dynamic_cast<Acoustics::FITKSEASubSysShellRadiationWare*>(SubSysShell);
    if (p2 == nullptr)
    {
        return false;
    }
    this->readSEASubSysShellRadiationWare(gp, p2);
    return true;
}
bool IO::FITKAcousticsSEASubSysMgrAdaptor::writeSEASubSysShellRadiationWare(H5::Group & gp, Acoustics::FITKSEASubSysShellRadiationWare * SubSysShellRadiationWare)
{
    if (SubSysShellRadiationWare == nullptr)
    {
        return false;
    }
    //写父类FITKSEASubSysShellRadiationWare
    double EffRadiationAreaMagnification = SubSysShellRadiationWare->getEffRadiationAreaMagnification();//有效辐射面积放大倍数
    double EffRadiationPerimeterMagnification = SubSysShellRadiationWare->getEffRadiationPerimeterMagnification();//有效辐射周长放大倍数
    bool FlexureInSEAMatrixSolution = SubSysShellRadiationWare->getFlexureInSEAMatrixSolution();//SEA解决方案是否包含弯曲波
    bool FlexureCorrectionSDP = SubSysShellRadiationWare->getFlexureCorrectionSDP();//弯曲波对分层面板校正的启用状态
    double FlexureSDPLengthMagnification = SubSysShellRadiationWare->getFlexureSDPLengthMagnification();//弯曲波对分层面板的长的放大倍数
    double FlexureSDPWidthMagnification = SubSysShellRadiationWare->getFlexureSDPWidthMagnification();//弯曲波对分层面板的宽的放大倍数
    bool FlexureModelDensityState = SubSysShellRadiationWare->getFlexureModelDensityState();//弯曲波对模态密度的启用状态
    int FlexureModelDensityID = SubSysShellRadiationWare->getFlexureModelDensityID();//弯曲波的模态密度
    bool ExtensionInSEAMatrixSolution = SubSysShellRadiationWare->getExtensionInSEAMatrixSolution();//SEA解决方案是否包含拉伸波
    bool ExtensionModelDensityState = SubSysShellRadiationWare->getExtensionModelDensityState();//拉伸波对模态密度的启用状态
    int ExtensionModelDensityID = SubSysShellRadiationWare->getExtensionModelDensityID();//拉伸波的模态密度
    bool ShearInSEAMatrixSolution = SubSysShellRadiationWare->getShearInSEAMatrixSolution();//SEA解决方案是否包含剪切波
    bool ShearModelDensityState = SubSysShellRadiationWare->getShearModelDensityState();//剪切波对模态密度的启用状态
    int ShearModelDensityID = SubSysShellRadiationWare->getShearModelDensityID();//剪切波的模态密度

    m_toolp->writeGroupAttrDouble(gp, "EffRadiationAreaMagnification", EffRadiationAreaMagnification);
    m_toolp->writeGroupAttrDouble(gp, "EffRadiationPerimeterMagnification", EffRadiationPerimeterMagnification);
    m_toolp->writeGroupAttrInt(gp, "FlexureInSEAMatrixSolution", FlexureInSEAMatrixSolution == true ? 1 : 0);
    m_toolp->writeGroupAttrInt(gp, "FlexureCorrectionSDP", FlexureCorrectionSDP == true ? 1 : 0);
    m_toolp->writeGroupAttrDouble(gp, "FlexureSDPLengthMagnification", FlexureSDPLengthMagnification);
    m_toolp->writeGroupAttrDouble(gp, "FlexureSDPWidthMagnification", FlexureSDPWidthMagnification);
    m_toolp->writeGroupAttrInt(gp, "FlexureModelDensityState", FlexureModelDensityState == true ? 1 : 0);
    m_toolp->writeGroupAttrInt(gp, "FlexureModelDensityID", FlexureModelDensityID);
    m_toolp->writeGroupAttrInt(gp, "ExtensionInSEAMatrixSolution", ExtensionInSEAMatrixSolution == true ? 1 : 0);
    m_toolp->writeGroupAttrInt(gp, "ExtensionModelDensityState", ExtensionModelDensityState == true ? 1 : 0);
    m_toolp->writeGroupAttrInt(gp, "ExtensionModelDensityID", ExtensionModelDensityID);
    m_toolp->writeGroupAttrInt(gp, "ShearInSEAMatrixSolution", ShearInSEAMatrixSolution == true ? 1 : 0);
    m_toolp->writeGroupAttrInt(gp, "ShearModelDensityState", ShearModelDensityState == true ? 1 : 0);
    m_toolp->writeGroupAttrInt(gp, "ShearModelDensityID", ShearModelDensityID);
    return true;
}
bool IO::FITKAcousticsSEASubSysMgrAdaptor::readSEASubSysShellRadiationWare(H5::Group & gp, Acoustics::FITKSEASubSysShellRadiationWare * SubSysShellRadiationWare)
{
    if (SubSysShellRadiationWare == nullptr)
    {
        return false;
    }
    //父类FITKSEASubSysShellRadiationWare
    double EffRadiationAreaMagnification = 0.0;//有效辐射面积放大倍数
    double EffRadiationPerimeterMagnification = 0.0;//有效辐射周长放大倍数
    int FlexureInSEAMatrixSolution = false;//SEA解决方案是否包含弯曲波
    int FlexureCorrectionSDP = false;//弯曲波对分层面板校正的启用状态
    double FlexureSDPLengthMagnification = 0.0;//弯曲波对分层面板的长的放大倍数
    double FlexureSDPWidthMagnification = 0.0;//弯曲波对分层面板的宽的放大倍数
    int FlexureModelDensityState = false;//弯曲波对模态密度的启用状态
    int FlexureModelDensityID = -1;//弯曲波的模态密度
    int ExtensionInSEAMatrixSolution = false;//SEA解决方案是否包含拉伸波
    int ExtensionModelDensityState = false;//拉伸波对模态密度的启用状态
    int ExtensionModelDensityID = -1;//拉伸波的模态密度
    int ShearInSEAMatrixSolution = false;//SEA解决方案是否包含剪切波
    int ShearModelDensityState = false;//剪切波对模态密度的启用状态
    int ShearModelDensityID = -1;//剪切波的模态密度

    m_toolp->readGroupDouble(gp, "EffRadiationAreaMagnification", &EffRadiationAreaMagnification);
    m_toolp->readGroupDouble(gp, "EffRadiationPerimeterMagnification", &EffRadiationPerimeterMagnification);
    m_toolp->readGroupint(gp, "FlexureInSEAMatrixSolution", &FlexureInSEAMatrixSolution);
    m_toolp->readGroupint(gp, "FlexureCorrectionSDP", &FlexureCorrectionSDP);
    m_toolp->readGroupDouble(gp, "FlexureSDPLengthMagnification", &FlexureSDPLengthMagnification);
    m_toolp->readGroupDouble(gp, "FlexureSDPWidthMagnification", &FlexureSDPWidthMagnification);
    m_toolp->readGroupint(gp, "FlexureModelDensityState", &FlexureModelDensityState);
    m_toolp->readGroupint(gp, "FlexureModelDensityID", &FlexureModelDensityID);
    m_toolp->readGroupint(gp, "ExtensionInSEAMatrixSolution", &ExtensionInSEAMatrixSolution);
    m_toolp->readGroupint(gp, "ExtensionModelDensityState", &ExtensionModelDensityState);
    m_toolp->readGroupint(gp, "ExtensionModelDensityID", &ExtensionModelDensityID);
    m_toolp->readGroupint(gp, "ShearInSEAMatrixSolution", &ShearInSEAMatrixSolution);
    m_toolp->readGroupint(gp, "ShearModelDensityState", &ShearModelDensityState);
    m_toolp->readGroupint(gp, "ShearModelDensityID", &ShearModelDensityID);


    SubSysShellRadiationWare->setEffRadiationAreaMagnification(EffRadiationAreaMagnification);
    SubSysShellRadiationWare->setEffRadiationPerimeterMagnification(EffRadiationPerimeterMagnification);
    SubSysShellRadiationWare->setFlexureInSEAMatrixSolution(FlexureInSEAMatrixSolution == 1 ? true : false);
    SubSysShellRadiationWare->setFlexureCorrectionSDP(FlexureCorrectionSDP == 1 ? true : false);
    SubSysShellRadiationWare->setFlexureSDPLengthMagnification(FlexureSDPLengthMagnification);
    SubSysShellRadiationWare->setFlexureSDPWidthMagnification(FlexureSDPWidthMagnification);
    SubSysShellRadiationWare->setFlexureModelDensityState(FlexureModelDensityState == 1 ? true : false);
    SubSysShellRadiationWare->setFlexureModelDensityID(FlexureModelDensityID);
    SubSysShellRadiationWare->setExtensionInSEAMatrixSolution(ExtensionInSEAMatrixSolution == 1 ? true : false);
    SubSysShellRadiationWare->setExtensionModelDensityState(ExtensionModelDensityState == 1 ? true : false);
    SubSysShellRadiationWare->setExtensionModelDensityID(ExtensionModelDensityID);
    SubSysShellRadiationWare->setShearInSEAMatrixSolution(ShearInSEAMatrixSolution == 1 ? true : false);
    SubSysShellRadiationWare->setShearModelDensityState(ShearModelDensityState == 1 ? true : false);
    SubSysShellRadiationWare->setShearModelDensityID(ShearModelDensityID);

    return true;
}
bool IO::FITKAcousticsSEASubSysMgrAdaptor::writeSEASubSys(H5::Group & gp, Acoustics::FITKAbstractSEASubSys * subSysp)
{
    if (subSysp == nullptr)
    {
        return false;
    }
    //父类FITKAbstractSEASubSys
    int PropSectionID = subSysp->getPropSectionID();//物理属性ID
    int MaterialID = subSysp->getMaterialID();//材料ID
    Acoustics::FITKSEASubSysGeoProp* GeoProp = subSysp->getGeoProp();//几何属性 不写 回显时调用一下初始化函数
    Interface::FITKCoordinateSystem* CoordinateSys = subSysp->getCoordinateSys();//坐标 --不写 回显时调用一下初始化函数
    if (CoordinateSys == nullptr)
    {
        return false;
    }
    int CoordID = CoordinateSys->getDataObjectID();
    QString CoordName = CoordinateSys->getDataObjectName();

    m_toolp->writeGroupAttrInt(gp, "PropSectionID", PropSectionID);
    m_toolp->writeGroupAttrInt(gp, "MaterialID", MaterialID);
    m_toolp->writeGroupAttrInt(gp, "CoordID", CoordID);
    m_toolp->writeGroupAttrStr(gp, "CoordName", CoordName.toStdString());


    //FITKAbstractSEASubSys/FITKAbstractNDataObject
    QString DataObjectName = subSysp->getDataObjectName();//对象名称
    int ID = subSysp->getDataObjectID();

    m_toolp->writeGroupAttrStr(gp, "DataObjectName", DataObjectName.toStdString());
    m_toolp->writeGroupAttrInt(gp, "ID", ID);
}
bool IO::FITKAcousticsSEASubSysMgrAdaptor::readSEASubSys(H5::Group & gp, Acoustics::FITKAbstractSEASubSys * subSysp)
{
    if (subSysp == nullptr)
    {
        return false;
    }
    //父类FITKAbstractSEASubSys
    int PropSectionID = -1;//物理属性ID
    int MaterialID = -1;//材料ID

    int CoordID = -1;
    std::string CoordName = "";

    m_toolp->readGroupint(gp, "PropSectionID", &PropSectionID);
    m_toolp->readGroupint(gp, "MaterialID", &MaterialID);
    m_toolp->readGroupint(gp, "CoordID", &CoordID);
    m_toolp->readGroupStr(gp, "CoordName", CoordName);


    subSysp->setPropSection(PropSectionID);
    subSysp->setMaterialID(MaterialID);

    Interface::FITKCoordinateSystem*Coordp = subSysp->getCoordinateSys();//坐标 回显时调用一下初始化函数
    Core::FITKAbstractDataIDAlter a;
    a.modifyDataID(Coordp, CoordID);
    QString CoorDname = QString::fromStdString(CoordName);
    m_toolp->CheckString(CoorDname);
    Coordp->setDataObjectName(CoorDname);


    //FITKAbstractSEASubSys/FITKAbstractNDataObject
    std::string DataObjectName = "";//对象名称
    int ID = -1;

    m_toolp->readGroupStr(gp, "DataObjectName", DataObjectName);
    m_toolp->readGroupint(gp, "ID", &ID);

    QString tempDataObjectName = QString::fromStdString(DataObjectName);
    m_toolp->CheckString(tempDataObjectName);
    subSysp->setDataObjectName(tempDataObjectName);

    a.modifyDataID(subSysp, ID);
    return true;
}
bool IO::FITKAcousticsSEASubSysMgrAdaptor::readSEACavitys(H5::Group & gp, Acoustics::FITKAcousticsSEASubSysManager * mager)
{
    if (mager == nullptr)
    {
        return false;
    }
    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(gp, "SEACavitys");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisGroup, "SEACavitysCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);
    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        QString number = QString::number(i);
        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, number.toStdString().data());//打开子节点
        if (std::get<0>(Ret) == false) { return false; }
        H5::Group subGroup = std::get<1>(Ret);

        Acoustics::FITKSEASubSysCavity*Cavity = new Acoustics::FITKSEASubSysCavity;//声腔子系统

        std::vector<int>shellIDList;//板ID列表
        //以下3个变量由_v_a_p拆分
        double Perimeter = 0.0;//周长_v_a_p[2]
        double SurfaceArea = 0.0;//表面积_v_a_p[1]
        double Volume = 0.0;//体积_v_a_p[0]

        int DampingID = -1;//阻尼ID
        int ModalDensity = -1;//模态密度
        int InSEAMatrixSolution = true;//压力启用状态

        m_toolp->readGroupDouble(subGroup, "Perimeter", &Perimeter);
        m_toolp->readGroupDouble(subGroup, "SurfaceArea", &SurfaceArea);
        m_toolp->readGroupDouble(subGroup, "Volume", &Volume);

        m_toolp->readGroupint(subGroup, "DampingID", &DampingID);
        m_toolp->readGroupint(subGroup, "ModalDensity", &ModalDensity);
        m_toolp->readGroupint(subGroup, "InSEAMatrixSolution", &InSEAMatrixSolution);
        m_toolp->ReadOneDArrayDataSetInt(subGroup, "shellIDList", shellIDList);

        Cavity->setPerimeter(Perimeter);
        Cavity->setSurfaceArea(SurfaceArea);
        Cavity->setVolume(Volume);
        Cavity->setDampingID(DampingID);
        Cavity->setModalDensity(ModalDensity);
        Cavity->setInSEAMatrixSolution(InSEAMatrixSolution == 1 ? true : false);
        for (int j = 0; j < shellIDList.size(); ++j)
        {
            Cavity->appendShell(shellIDList.at(j));
        }

        Acoustics::FITKAbstractSEASubSys*CavityParent = dynamic_cast<Acoustics::FITKAbstractSEASubSys*>(Cavity);//声腔子系统父类转换
        if (CavityParent == nullptr)
        {
            return false;
        }
        this->readSEASubSys(subGroup, CavityParent);//填充父类
        mager->appendDataObj(Cavity);
    }
    return true;
}
bool IO::FITKAcousticsSEASubSysMgrAdaptor::writeSEACavitys(H5::Group & gp, QList<Acoustics::FITKAbstractSEASubSys*> SEACavitys)
{
    //创建的HDF5目录结构
    const char *Path = "SEAModel/SEACavitys";

    int count = SEACavitys.size();//获取数据行数

    //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(gp, "SEACavitys", "SEACavitysCount", count);

    H5::Group thisGroup = m_toolp->GetPathGroup(Path);

    for (int i = 0; i < count; ++i)
    {
        Acoustics::FITKAbstractSEASubSys* subp = SEACavitys.at(i);
        if (subp == nullptr)
        {
            return false;
        }
        Acoustics::FITKSEASubSysCavity*Cavity = dynamic_cast<Acoustics::FITKSEASubSysCavity*>(subp);//声腔子系统
        if (Cavity == nullptr)
        {
            return false;
        }

        QString number = QString::number(i);
        std::tuple<bool, H5::Group>Ret = m_toolp->createGp(thisGroup, number.toStdString().data());//创建子节点
        if (std::get<0>(Ret) == false) { return false; }
        H5::Group subGroup = std::get<1>(Ret);

        std::vector<int>shellIDList;//板ID列表
        int ShellCount = Cavity->getShellCount();//板个数
        for (int j = 0; j < ShellCount; ++j)
        {
            shellIDList.push_back(Cavity->getShellID(j));
        }

        //QList<int> _faceIDList{};  可能会填

        //以下3个变量由_v_a_p拆分
        double Perimeter = Cavity->getPerimeter();//周长_v_a_p[2]
        double SurfaceArea = Cavity->getSurfaceArea();//表面积_v_a_p[1]
        double Volume = Cavity->getVolume();//体积_v_a_p[0]

        int DampingID = Cavity->getDampingID();//阻尼ID
        int ModalDensity = Cavity->getModalDensity();//模态密度
        bool InSEAMatrixSolution = Cavity->getInSEAMatrixSolution();//压力启用状态


        m_toolp->writeGroupAttrDouble(subGroup, "Perimeter", Perimeter);
        m_toolp->writeGroupAttrDouble(subGroup, "SurfaceArea", SurfaceArea);
        m_toolp->writeGroupAttrDouble(subGroup, "Volume", Volume);
        m_toolp->writeGroupAttrInt(subGroup, "DampingID", DampingID);
        m_toolp->writeGroupAttrInt(subGroup, "ModalDensity", ModalDensity);
        m_toolp->writeGroupAttrInt(subGroup, "InSEAMatrixSolution", InSEAMatrixSolution == true ? 1 : 0);
        m_toolp->CreateOneDarrayDataSetInt(subGroup, "shellIDList", shellIDList);
        this->writeSEASubSys(subGroup, subp);//写父类
    }

    return true;
}
bool IO::FITKAcousticsSEASubSysMgrAdaptor::readDoublyCurvedShells(H5::Group & gp, Acoustics::FITKAcousticsSEASubSysManager * mager)
{
    if (mager == nullptr)
    {
        return false;
    }
    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(gp, "SEADoublyCurvedShells");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisGroup, "SEADoublyCurvedShellsCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);
    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        QString number = QString::number(i);
        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, number.toStdString().data());
        if (std::get<0>(Ret) == false) { return false; }
        H5::Group subGroup = std::get<1>(Ret);

        /*
        FITKSEASubSysSinglyCurvedShell->继承FITKAbstractSEASubSysShell
                                            FITKAbstractSEASubSysShell->继承FITKAbstractSEASubSysWithNodes
                                            FITKAbstractSEASubSysShell->继承FITKSEASubSysShellRadiationWare
        */
        Acoustics::FITKSEASubSysDoublyCurvedShell*DoublyCurvedShellP = new Acoustics::FITKSEASubSysDoublyCurvedShell;
        Acoustics::FITKAbstractSEASubSysShell*CurvedShellPParent = dynamic_cast<Acoustics::FITKAbstractSEASubSysShell*>(DoublyCurvedShellP);//父类转换
        if (CurvedShellPParent == nullptr)
        {
            return false;
        }

        this->readSEASubSysShell(subGroup, CurvedShellPParent);//读父类
        DoublyCurvedShellP->updateGeoProp();//更新几何属性
        mager->appendDataObj(DoublyCurvedShellP);
    }
    return true;
}
bool IO::FITKAcousticsSEASubSysMgrAdaptor::writeSemiIInfiniteFluids(H5::Group & gp, QList<Acoustics::FITKAbstractSEASubSys*> SemiIInfiniteFluids)
{
    //创建的HDF5目录结构
    const char *Path = "SEAModel/SemiIInfiniteFluids";

    int count = SemiIInfiniteFluids.size();//获取数据行数

    //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(gp, "SemiIInfiniteFluids", "SemiIInfiniteFluidsCount", count);

    //获取刚刚创建的组
    H5::Group thisGroup = m_toolp->GetPathGroup(Path);

    for (int i = 0; i < SemiIInfiniteFluids.size(); i++)
    {
        Acoustics::FITKAbstractSEASubSys*subp = SemiIInfiniteFluids.at(i);
        if (subp == nullptr)
        {
            return false;
        }
        Acoustics::FITKSEASubSysSemiInfiniteFluid*SemiInfiniteFluid = dynamic_cast<Acoustics::FITKSEASubSysSemiInfiniteFluid*>(subp);
        if (SemiInfiniteFluid == nullptr)
        {
            return false;
        }
        int NodeID = SemiInfiniteFluid->getNodeID();//节点ID
        bool IsEnabled = SemiInfiniteFluid->getIsEnabled();//是否有效
        bool IsOveSPLDistances = SemiInfiniteFluid->getIsOveSPLDistances();//是否覆盖SPL距离

        QString number = QString::number(i);
        std::tuple<bool, H5::Group>Ret = m_toolp->createGp(thisGroup, number.toStdString().data());//创建子节点
        if (std::get<0>(Ret) == false) { return false; }
        H5::Group subGroup = std::get<1>(Ret);

        m_toolp->writeGroupAttrInt(subGroup, "NodeID", NodeID);
        m_toolp->writeGroupAttrInt(subGroup, "IsEnabled", IsEnabled == true ? 1 : 0);
        m_toolp->writeGroupAttrInt(subGroup, "IsOveSPLDistances", IsOveSPLDistances == true ? 1 : 0);


        Acoustics::FITKAbstractSEASubSys*p1 = dynamic_cast<Acoustics::FITKAbstractSEASubSys*>(subp);
        if (p1 == nullptr)
        {
            return false;
        }
        this->writeSEASubSys(subGroup, p1);//写父类


        int DataCount = SemiInfiniteFluid->getDataCount();
        m_toolp->writeGroupAttrInt(subGroup, "DataCount", DataCount);//写子节点的子节点有多少个
        for (int j = 0; j < DataCount; ++j)
        {
            Acoustics::FITKSEASubSysSEIFConnectedSubSys *SEIFConnectedSubSysP = SemiInfiniteFluid->getDataByIndex(j);
            if (SEIFConnectedSubSysP == nullptr)
            {
                return false;
            }

            std::tuple<bool, H5::Group>Retj = m_toolp->createGp(subGroup, QString::number(j));//创建子节点的子节点
            if (std::get<0>(Retj) == false) { return false; }
            H5::Group subGroupj = std::get<1>(Retj);

            double pointPos[3] = { 0.0,0.0,0.0 };
            SEIFConnectedSubSysP->getConnectPos(pointPos);//连接位置
            std::vector<double>tempVt = { pointPos[0],pointPos[1],pointPos[2] };

            int RadLossFactor = SEIFConnectedSubSysP->getRadLossFactor();//损耗因子id
            double Distance = SEIFConnectedSubSysP->getDistance();//距离
            int cavityFaceID = SEIFConnectedSubSysP->getCavityFaceID(); //面ID，只对声腔子系统有效
            int subSystemID = SEIFConnectedSubSysP->getSubSysID();//子系统ID
            int SEIFConnectedSubSysID=SEIFConnectedSubSysP->getDataObjectID();//数据ID

            m_toolp->writeGroupAttrInt(subGroupj, "RadLossFactor", RadLossFactor);
            m_toolp->writeGroupAttrDouble(subGroupj, "Distance", Distance);
            m_toolp->writeGroupAttrInt(subGroupj, "cavityFaceID", cavityFaceID);
            m_toolp->writeGroupAttrInt(subGroupj, "subSystemID", subSystemID);
            m_toolp->writeGroupAttrInt(subGroupj, "SEIFConnectedSubSysID", SEIFConnectedSubSysID);
            m_toolp->CreateOneDarrayDataSetDouble(subGroupj, "pointPos", tempVt);

 

        }
    }

    return true;
}
bool IO::FITKAcousticsSEASubSysMgrAdaptor::readSemiIInfiniteFluids(H5::Group & gp, Acoustics::FITKAcousticsSEASubSysManager * mager)
{
    if (mager == nullptr)
    {
        return false;
    }
    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(gp, "SemiIInfiniteFluids");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisGroup, "SemiIInfiniteFluidsCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);
    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        QString number = QString::number(i);
        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, number.toStdString().data());
        if (std::get<0>(Ret) == false) { return false; }
        H5::Group subGroup = std::get<1>(Ret);

        Acoustics::FITKSEASubSysSemiInfiniteFluid*SemiInfiniteFluid = new Acoustics::FITKSEASubSysSemiInfiniteFluid;


        int NodeID =-1;//节点ID
        int IsEnabled =false;//是否有效
        int IsOveSPLDistances = false;//是否覆盖SPL距离

        m_toolp->readGroupint(subGroup, "NodeID", &NodeID);
        m_toolp->readGroupint(subGroup, "IsEnabled", &IsEnabled);
        m_toolp->readGroupint(subGroup, "IsOveSPLDistances", &IsOveSPLDistances);

        SemiInfiniteFluid->setNodeID(NodeID);
        SemiInfiniteFluid->setIsEnabled(IsEnabled == 1 ? true : false);
        SemiInfiniteFluid->setIsOveSPLDistances(IsOveSPLDistances == 1 ? true : false);

        Acoustics::FITKAbstractSEASubSys*p1 = dynamic_cast<Acoustics::FITKAbstractSEASubSys*>(SemiInfiniteFluid);
        if (p1 == nullptr)
        {
            return false;
        }
        this->readSEASubSys(subGroup, p1);//读父类
        int DataCount = -1;
        m_toolp->readGroupint(subGroup, "DataCount", &DataCount);//读取包层数
        for (int j = 0; j < DataCount; ++j)
        {
            QString lay = QString::number(j);
            std::tuple<bool, H5::Group>layRet = m_toolp->openGp(subGroup, lay.toStdString().data());
            if (std::get<0>(layRet) == false) { continue; }
            H5::Group layGroup = std::get<1>(layRet);

            int RadLossFactor=-1;//损耗因子id
            double Distance =0.0;//距离
            int cavityFaceID =-1; //面ID，只对声腔子系统有效
            int subSystemID =-1;//子系统ID
            int SEIFConnectedSubSysID = -1;//数据ID

            m_toolp->readGroupint(layGroup, "RadLossFactor", &RadLossFactor);
            m_toolp->readGroupDouble(layGroup, "Distance", &Distance);
            m_toolp->readGroupint(layGroup, "cavityFaceID", &cavityFaceID);
            m_toolp->readGroupint(layGroup, "subSystemID", &subSystemID);
            m_toolp->readGroupint(layGroup, "SEIFConnectedSubSysID", &SEIFConnectedSubSysID);

            std::vector<double>pointPos;
            m_toolp->ReadOneDArrayDataSetDouble(layGroup, "pointPos", pointPos);
            double pointPosVt[3] = { pointPos.at(0), pointPos.at(1),pointPos.at(2) };

            Acoustics::FITKSEASubSysSEIFConnectedSubSys *SEIFConnectedSubSysP = new Acoustics::FITKSEASubSysSEIFConnectedSubSys;
            SEIFConnectedSubSysP->setRadLossFactorID(RadLossFactor);
            SEIFConnectedSubSysP->setDistance(Distance);
            SEIFConnectedSubSysP->setCavityFaceID(cavityFaceID);
            SEIFConnectedSubSysP->setSubSysID(subSystemID);
            SEIFConnectedSubSysP->setConnectPos(pointPosVt);
           
            Core::FITKAbstractDataIDAlter a;
            a.modifyDataID(SEIFConnectedSubSysP, SEIFConnectedSubSysID);//设置数据ID

            SemiInfiniteFluid->insertDataObj(j, SEIFConnectedSubSysP);
        }
        mager->appendDataObj(SemiInfiniteFluid);
    }
    return true;
}
bool IO::FITKAcousticsSEASubSysMgrAdaptor::writeDoublyCurvedShells(H5::Group & gp, QList<Acoustics::FITKAbstractSEASubSys*> SEADoublyCurvedShells)
{
    //创建的HDF5目录结构
    const char *Path = "SEAModel/SEADoublyCurvedShells";

    int count = SEADoublyCurvedShells.size();//获取数据行数

    //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(gp, "SEADoublyCurvedShells", "SEADoublyCurvedShellsCount", count);

    //获取刚刚创建的组
    H5::Group thisGroup = m_toolp->GetPathGroup(Path);

    for (int i = 0; i < SEADoublyCurvedShells.size(); i++)
    {
        Acoustics::FITKAbstractSEASubSys* subp = SEADoublyCurvedShells.at(i);
        if (subp == nullptr)
        {
            return false;
        }
        Acoustics::FITKSEASubSysDoublyCurvedShell*DoublyCurvedShells = dynamic_cast<Acoustics::FITKSEASubSysDoublyCurvedShell*>(subp);
        if (DoublyCurvedShells == nullptr)
        {
            return false;
        }
        QString number = QString::number(i);
        std::tuple<bool, H5::Group>Ret = m_toolp->createGp(thisGroup, number.toStdString().data());//创建子节点
        if (std::get<0>(Ret) == false) { return false; }
        H5::Group subGroup = std::get<1>(Ret);

        Acoustics::FITKAbstractSEASubSysShell*SEASubSysShellP = dynamic_cast<Acoustics::FITKAbstractSEASubSysShell*>(DoublyCurvedShells);
        this->writeSEASubSysShell(subGroup, SEASubSysShellP);//写父类

    }
    return true;
}
bool IO::FITKAcousticsSEASubSysMgrAdaptor::writeSinglyCurvedShells(H5::Group & gp, QList<Acoustics::FITKAbstractSEASubSys*> SinglyCurvedShells)
{
    //创建的HDF5目录结构
    const char *Path = "SEAModel/SinglyCurvedShells";

    int count = SinglyCurvedShells.size();//获取数据行数

    //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(gp, "SinglyCurvedShells", "SinglyCurvedShellsCount", count);

    //获取刚刚创建的组
    H5::Group thisGroup = m_toolp->GetPathGroup(Path);

    for (int i = 0; i < SinglyCurvedShells.size(); i++)
    {
        Acoustics::FITKAbstractSEASubSys* subp = SinglyCurvedShells.at(i);
        if (subp == nullptr)
        {
            return false;
        }
        Acoustics::FITKSEASubSysSinglyCurvedShell*SinglyCurvedShell = dynamic_cast<Acoustics::FITKSEASubSysSinglyCurvedShell*>(subp);
        if (SinglyCurvedShell == nullptr)
        {
            return false;
        }
        QString number = QString::number(i);
        std::tuple<bool, H5::Group>Ret = m_toolp->createGp(thisGroup, number.toStdString().data());//创建子节点
        if (std::get<0>(Ret) == false) { return false; }
        H5::Group subGroup = std::get<1>(Ret);

        Acoustics::FITKAbstractSEASubSysShell*SEASubSysShellP = dynamic_cast<Acoustics::FITKAbstractSEASubSysShell*>(SinglyCurvedShell);
        this->writeSEASubSysShell(subGroup, SEASubSysShellP);//写父类

    }
    return true;
}
bool IO::FITKAcousticsSEASubSysMgrAdaptor::readSinglyCurvedShells(H5::Group & gp, Acoustics::FITKAcousticsSEASubSysManager * mager)
{
    if (mager == nullptr)
    {
        return false;
    }
    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(gp, "SinglyCurvedShells");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisGroup, "SinglyCurvedShellsCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);
    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        QString number = QString::number(i);
        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, number.toStdString().data());
        if (std::get<0>(Ret) == false) { return false; }
        H5::Group subGroup = std::get<1>(Ret);

        /*
        FITKSEASubSysSinglyCurvedShell->继承FITKAbstractSEASubSysShell
                                            FITKAbstractSEASubSysShell->继承FITKAbstractSEASubSysWithNodes
                                            FITKAbstractSEASubSysShell->继承FITKSEASubSysShellRadiationWare
        */
        Acoustics::FITKSEASubSysSinglyCurvedShell*SinglyCurvedShellP = new Acoustics::FITKSEASubSysSinglyCurvedShell;
        Acoustics::FITKAbstractSEASubSysShell*CurvedShellParent = dynamic_cast<Acoustics::FITKAbstractSEASubSysShell*>(SinglyCurvedShellP);//父类转换
        if (CurvedShellParent == nullptr)
        {
            return false;
        }
        this->readSEASubSysShell(subGroup, CurvedShellParent);//读父类
        SinglyCurvedShellP->updateGeoProp();//更新几何属性
        mager->appendDataObj(SinglyCurvedShellP);
    }
    return true;
}
bool IO::FITKAcousticsSEASubSysMgrAdaptor::writeSEAFlatPlates(H5::Group &gp, QList<Acoustics::FITKAbstractSEASubSys*> FlatPlates)
{
    //创建的HDF5目录结构
    const char *Path = "SEAModel/FlatPlates";

    int count = FlatPlates.size();//获取数据行数

    //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(gp, "FlatPlates", "FlatPlatesCount", count);

    //获取刚刚创建的组
    H5::Group thisGroup = m_toolp->GetPathGroup(Path);

    for (int i = 0; i < FlatPlates.size(); i++)
    {
        Acoustics::FITKAbstractSEASubSys* subp = FlatPlates.at(i);
        if (subp == nullptr)
        {
            return false;
        }

        Acoustics::FITKSEASubSysPlateShell*Plate = dynamic_cast<Acoustics::FITKSEASubSysPlateShell*>(subp);
        if (Plate == nullptr)
        {
            return false;
        }
        QString number = QString::number(i);
        std::tuple<bool, H5::Group>Ret = m_toolp->createGp(thisGroup, number.toStdString().data());//创建子节点
        if (std::get<0>(Ret) == false) { return false; }
        H5::Group subGroup = std::get<1>(Ret);

        Acoustics::FITKAbstractSEASubSysShell*SubSysShellP = dynamic_cast<Acoustics::FITKAbstractSEASubSysShell*>(Plate);
        if (SubSysShellP == nullptr)
        {
            return false;
        }
        this->writeSEASubSysShell(subGroup, SubSysShellP);//写FITKAbstractSEASubSysShell
        /*
        FITKSEASubSysPlateShell->继承FITKAbstractSEASubSysShell
                                     FITKAbstractSEASubSysShell->继承FITKAbstractSEASubSysWithNodes
                                                                     FITKAbstractSEASubSysWithNodes->继承FITKAbstractSEASubSys
                                     FITKAbstractSEASubSysShell->继承FITKSEASubSysShellRadiationWare
        writeSEASubSysShell函数按照继承顺序写入，直到FITKAbstractSEASubSys
        */
    }
    return true;
}
bool IO::FITKAcousticsSEASubSysMgrAdaptor::readSEAFlatPlates(H5::Group & gp, Acoustics::FITKAcousticsSEASubSysManager * mager)
{
    if (mager == nullptr)
    {
        return false;
    }
    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(gp, "FlatPlates");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisGroup, "FlatPlatesCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);
    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        QString number = QString::number(i);
        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, number.toStdString().data());
        if (std::get<0>(Ret) == false) { return false; }
        H5::Group subGroup = std::get<1>(Ret);

        int FlexureSpectraID = -1;//弯曲波频谱id
        int ExtensionSpectraID = -1;// 拉伸波频谱id
        int ShearSpectraID = -1;//剪切波频谱id
        int FromUserSpectraState = false;//来自用户光谱开启状态
        int FromPhysicalPropState = false;//来自物理属性开启状态
        int FromNoiseControlState = false;//来自噪声控制开启状态

        Acoustics::FITKSEASubSysPlateShell*Plate = new Acoustics::FITKSEASubSysPlateShell;

        Acoustics::FITKAbstractSEASubSysShell* p1 = dynamic_cast<Acoustics::FITKAbstractSEASubSysShell*>(Plate);

        /*
       FITKSEASubSysPlateShell->继承FITKAbstractSEASubSysShell
                                    FITKAbstractSEASubSysShell->继承FITKAbstractSEASubSysWithNodes
                                                                    FITKAbstractSEASubSysWithNodes->继承FITKAbstractSEASubSys
                                    FITKAbstractSEASubSysShell->继承FITKSEASubSysShellRadiationWare
       readSEASubSysShell函数按照继承顺序回写数据

       */
        this->readSEASubSysShell(subGroup, p1);

        //Plate->updateTriMesh();//更新三角网格
        Plate->updateGeoProp();//更新几何属性
        mager->appendDataObj(Plate);
    }
    return true;
}
bool IO::FITKAcousticsSEASubSysMgrAdaptor::readSEABeams(H5::Group & gp, Acoustics::FITKAcousticsSEASubSysManager * mager)
{
    if (mager == nullptr)
    {
        return false;
    }
    std::tuple<bool, H5::Group>Ret = m_toolp->openGp(gp, "Beams");//打开组
    if (std::get<0>(Ret) == false) { return false; }
    H5::Group thisGroup = std::get<1>(Ret);

    std::tuple<bool, H5::Attribute>RetAttr = m_toolp->openAttribut(thisGroup, "BeamsCount"); //打开组个数属性
    if (std::get<0>(RetAttr) == false) { return false; }
    H5::Attribute CountAttrattr = std::get<1>(RetAttr);
    int count = -1;
    CountAttrattr.read(H5::PredType::NATIVE_INT, &count);

    for (int i = 0; i < count; ++i)
    {
        QString number = QString::number(i);
        std::tuple<bool, H5::Group>Ret = m_toolp->openGp(thisGroup, number.toStdString().data());//打开子节点
        if (std::get<0>(Ret) == false) { return false; }
        H5::Group subGroup = std::get<1>(Ret);

        Acoustics::FITKSEASubSysBeam*Beam = new Acoustics::FITKSEASubSysBeam;

        //本类
        int XID = -1;//弯曲波X频谱
        int YID = -1;//弯曲波Y频谱
        int ZID = -1;//拉伸波Z频谱
        int ZZID = -1;//扭转波ZZ频谱ID

        m_toolp->readGroupint(subGroup, "XID", &XID);
        m_toolp->readGroupint(subGroup, "YID", &YID);
        m_toolp->readGroupint(subGroup, "ZID", &ZID);
        m_toolp->readGroupint(subGroup, "ZZID", &ZZID);

        Beam->setFlexureXSpectraID(XID);
        Beam->setFlexureYSpectraID(YID);
        Beam->setExtensionZSpectraID(ZID);
        Beam->setTorsionZZSpectraID(ZZID);

        //父类FITKAbstractSEASubSysWithNodes
        Acoustics::FITKAbstractSEASubSysWithNodes* p1 =
            dynamic_cast<Acoustics::FITKAbstractSEASubSysWithNodes*>(Beam);
        if (p1 == nullptr)
        {
            return false;
        }
        this->readSEASubSysWithNodes(subGroup, p1);//读取基类数据，并填充




        //父类FITKSEASubSysBeamWare
        int TorsionZZModelDensityID = -1;//Torsion ZZ 模态密度ID
        int ExtensionZModelDensityID = -1;//Extension Z 模态密度ID
        int FlexureYModelDensityID = -1;//Flexure Y 模态密度ID
        int FlexureXModelDensityID = -1;//Flexure X 模态密度ID

        int TorsionZZModelDensityState = -1;//Torsion ZZ 是否重载模态密度
        int TorsionZZInSEAMatrixSolution = -1;//Torsion ZZ 是否启用解决方案
        int ExtensionZModelDensityState = -1;//Extension Z 是否重载模态密度
        int ExtensionZInSEAMatrixSolution = -1;//Extension Z 是否启用解决方案
        int FlexureYModelDensityState = -1;//Flexure Y 是否重载模态密度
        int FlexureYInSEAMatrixSolution = -1;//Flexure Y 是否启用解决方案
        int FlexureXModelDensityState = -1;//Flexure X 是否重载模态密度
        int FlexureXInSEAMatrixSolution = -1;//Flexure X 是否启用解决方案

        m_toolp->readGroupint(subGroup, "TorsionZZModelDensityID", &TorsionZZModelDensityID);
        m_toolp->readGroupint(subGroup, "ExtensionZModelDensityID", &ExtensionZModelDensityID);
        m_toolp->readGroupint(subGroup, "FlexureYModelDensityID", &FlexureYModelDensityID);
        m_toolp->readGroupint(subGroup, "FlexureXModelDensityID", &FlexureXModelDensityID);
        m_toolp->readGroupint(subGroup, "TorsionZZModelDensityState", &TorsionZZModelDensityState);
        m_toolp->readGroupint(subGroup, "TorsionZZInSEAMatrixSolution", &TorsionZZInSEAMatrixSolution);
        m_toolp->readGroupint(subGroup, "ExtensionZModelDensityState", &ExtensionZModelDensityState);
        m_toolp->readGroupint(subGroup, "ExtensionZInSEAMatrixSolution", &ExtensionZInSEAMatrixSolution);
        m_toolp->readGroupint(subGroup, "FlexureYModelDensityState", &FlexureYModelDensityState);
        m_toolp->readGroupint(subGroup, "FlexureYInSEAMatrixSolution", &FlexureYInSEAMatrixSolution);
        m_toolp->readGroupint(subGroup, "FlexureXModelDensityState", &FlexureXModelDensityState);
        m_toolp->readGroupint(subGroup, "FlexureXInSEAMatrixSolution", &FlexureXInSEAMatrixSolution);

        Beam->setTorsionZZModelDensityID(TorsionZZModelDensityID);
        Beam->setExtensionZModelDensityID(ExtensionZModelDensityID);
        Beam->setFlexureYModelDensityID(FlexureYModelDensityID);
        Beam->setFlexureXModelDensityID(FlexureXModelDensityID);
        Beam->setTorsionZZModelDensityState(TorsionZZModelDensityState == 1 ? true : false);
        Beam->setTorsionZZInSEAMatrixSolution(TorsionZZInSEAMatrixSolution == 1 ? true : false);
        Beam->setExtensionZModelDensityState(ExtensionZModelDensityState == 1 ? true : false);
        Beam->setExtensionZInSEAMatrixSolution(ExtensionZInSEAMatrixSolution == 1 ? true : false);
        Beam->setFlexureYModelDensityState(FlexureYModelDensityState == 1 ? true : false);
        Beam->setFlexureYInSEAMatrixSolution(FlexureYInSEAMatrixSolution == 1 ? true : false);
        Beam->setFlexureXModelDensityState(FlexureXModelDensityState == 1 ? true : false);
        Beam->setFlexureXInSEAMatrixSolution(FlexureXInSEAMatrixSolution == 1 ? true : false);
        Beam->updateGeoProp();//更新几何属性
        mager->appendDataObj(Beam);
    }
    return true;
}

bool IO::FITKAcousticsSEASubSysMgrAdaptor::readSEASubSysWithNodes(H5::Group & gp, Acoustics::FITKAbstractSEASubSysWithNodes *p)
{
    if (p == nullptr)
    {
        return false;
    }
    //父类FITKAbstractSEASubSysWithNodes
    int FaceID = -1;//基础面对象ID
    m_toolp->readGroupint(gp, "FaceID", &FaceID);
    p->setFaceID(FaceID);
    Acoustics::FITKAbstractSEASubSys*subp = dynamic_cast<Acoustics::FITKAbstractSEASubSys*>(p);
    if (subp == nullptr)
    {
        return false;
    }

    return this->readSEASubSys(gp, subp);
}

bool IO::FITKAcousticsSEASubSysMgrAdaptor::writeSEABeams(H5::Group gp, QList<Acoustics::FITKAbstractSEASubSys*> SEABeams)
{
    //创建的HDF5目录结构
    const char *Path = "SEAModel/Beams";

    int count = SEABeams.size();//获取数据行数

    //在组下创建组，并为组附加数据个数属性
    m_toolp->CreateGroupAndAttr(gp, "Beams", "BeamsCount", count);

    //获取刚刚创建的组
    H5::Group thisGroup = m_toolp->GetPathGroup(Path);

    for (int i = 0; i < SEABeams.size(); i++)
    {
        Acoustics::FITKAbstractSEASubSys* subp = SEABeams.at(i);
        if (subp == nullptr)
        {
            return false;
        }
        Acoustics::FITKSEASubSysBeam*Beam = dynamic_cast<Acoustics::FITKSEASubSysBeam*>(subp);
        if (Beam == nullptr)
        {
            return false;
        }
        QString number = QString::number(i);
        std::tuple<bool, H5::Group>Ret = m_toolp->createGp(thisGroup, number.toStdString().data());//创建子节点
        if (std::get<0>(Ret) == false) { return false; }
        H5::Group subGroup = std::get<1>(Ret);

        //本类
        int XID = Beam->getFlexureXSpectraID();//弯曲波X频谱
        int YID = Beam->getFlexureYSpectraID();//弯曲波Y频谱
        int ZID = Beam->getExtensionZSpectraID();//拉伸波Z频谱
        int ZZID = Beam->getTorsionZZSpectraID();//扭转波ZZ频谱ID

        m_toolp->writeGroupAttrInt(subGroup, "XID", XID);
        m_toolp->writeGroupAttrInt(subGroup, "YID", YID);
        m_toolp->writeGroupAttrInt(subGroup, "ZID", ZID);
        m_toolp->writeGroupAttrInt(subGroup, "ZZID", ZZID);

        //写父类FITKAbstractSEASubSysWithNodes数据
        Acoustics::FITKAbstractSEASubSysWithNodes* p1 =
            dynamic_cast<Acoustics::FITKAbstractSEASubSysWithNodes*>(Beam);
        if (p1 == nullptr)
        {
            return false;
        }
        this->writeSEASubSysWithNodes(subGroup, p1);


        //父类FITKSEASubSysBeamWare数据
        int TorsionZZModelDensityID = Beam->getTorsionZZModelDensityID();//Torsion ZZ 模态密度ID
        int ExtensionZModelDensityID = Beam->getExtensionZModelDensityID();//Extension Z 模态密度ID
        int FlexureYModelDensityID = Beam->getFlexureYModelDensityID();//Flexure Y 模态密度ID
        int FlexureXModelDensityID = Beam->getFlexureXModelDensityID();//Flexure X 模态密度ID

        bool TorsionZZModelDensityState = Beam->getTorsionZZModelDensityState();//Torsion ZZ 是否重载模态密度
        bool TorsionZZInSEAMatrixSolution = Beam->getTorsionZZInSEAMatrixSolution();//Torsion ZZ 是否启用解决方案
        bool ExtensionZModelDensityState = Beam->getExtensionZModelDensityState();//Extension Z 是否重载模态密度
        bool ExtensionZInSEAMatrixSolution = Beam->getExtensionZInSEAMatrixSolution();//Extension Z 是否启用解决方案
        bool FlexureYModelDensityState = Beam->getFlexureYModelDensityState();//Flexure Y 是否重载模态密度
        bool FlexureYInSEAMatrixSolution = Beam->getFlexureYInSEAMatrixSolution();//Flexure Y 是否启用解决方案
        bool FlexureXModelDensityState = Beam->getFlexureXModelDensityState();//Flexure X 是否重载模态密度
        bool FlexureXInSEAMatrixSolution = Beam->getFlexureXInSEAMatrixSolution();//Flexure X 是否启用解决方案

        m_toolp->writeGroupAttrInt(subGroup, "TorsionZZModelDensityID", TorsionZZModelDensityID);
        m_toolp->writeGroupAttrInt(subGroup, "ExtensionZModelDensityID", ExtensionZModelDensityID);
        m_toolp->writeGroupAttrInt(subGroup, "FlexureYModelDensityID", FlexureYModelDensityID);
        m_toolp->writeGroupAttrInt(subGroup, "FlexureXModelDensityID", FlexureXModelDensityID);
        m_toolp->writeGroupAttrInt(subGroup, "TorsionZZModelDensityState", TorsionZZModelDensityState == true ? 1 : 0);
        m_toolp->writeGroupAttrInt(subGroup, "TorsionZZInSEAMatrixSolution", TorsionZZInSEAMatrixSolution == true ? 1 : 0);
        m_toolp->writeGroupAttrInt(subGroup, "ExtensionZModelDensityState", ExtensionZModelDensityState == true ? 1 : 0);
        m_toolp->writeGroupAttrInt(subGroup, "ExtensionZInSEAMatrixSolution", ExtensionZInSEAMatrixSolution == true ? 1 : 0);
        m_toolp->writeGroupAttrInt(subGroup, "FlexureYModelDensityState", FlexureYModelDensityState == true ? 1 : 0);
        m_toolp->writeGroupAttrInt(subGroup, "FlexureYInSEAMatrixSolution", FlexureYInSEAMatrixSolution == true ? 1 : 0);
        m_toolp->writeGroupAttrInt(subGroup, "FlexureXModelDensityState", FlexureXModelDensityState == true ? 1 : 0);
        m_toolp->writeGroupAttrInt(subGroup, "FlexureXInSEAMatrixSolution", FlexureXInSEAMatrixSolution == true ? 1 : 0);
    }
    return true;
}

bool IO::FITKAcousticsSEASubSysMgrAdaptor::writeSEASubSysWithNodes(H5::Group gp, Acoustics::FITKAbstractSEASubSysWithNodes *p)
{
    if (p == nullptr)
    {
        return false;
    }

    //父类FITKAbstractSEASubSysWithNodes
    int FaceID = p->getFaceID();//基础面对象ID
    m_toolp->writeGroupAttrInt(gp, "FaceID", FaceID);

    Acoustics::FITKAbstractSEASubSys* subp = dynamic_cast<Acoustics::FITKAbstractSEASubSys*>(p);
    if (subp == nullptr)
    {
        return false;
    }
    //父类FITKAbstractSEASubSysWithNodes/FITKAbstractSEASubSys
    this->writeSEASubSys(gp, subp);
    return true;
}
